package ru.amse.tsyganov.jumleditor.commands;

import ru.amse.tsyganov.jumleditor.model.Transition;
import ru.amse.tsyganov.jumleditor.view.ModelViewMap;
import ru.amse.tsyganov.jumleditor.view.TransitionView;

/*package*/ class DeleteTransitionCommand<T extends Transition> extends Command {
	private final TransitionView<T> transitionView;
	
	public DeleteTransitionCommand(
			TransitionView<T> transitionView) {
		
		if (transitionView == null) {
			throw new IllegalArgumentException();
		}
		
		this.transitionView = transitionView;
	}
	
	@Override
	public void execute() {		
		Transition t = transitionView.getModel();
		t.getSource().getOutgoing().remove(t);
		t.getTarget().getIncoming().remove(t);	
	}

	@Override
	public void unexecute() {
		Transition t = transitionView.getModel();
		t.getSource().getOutgoing().add(t);
		t.getTarget().getIncoming().add(t);
	}

	@Override
	public void dispose() {
		//ModelViewMap.map.getTransitionsMap().
			//remove(transitionView.getModel());
	}
}
